package huawei;

import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

/**
 * 求质数因子
 *
 * @Author Jun jie Yi
 * 2022/4/4 13:20
 */
public class Demo2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int in = sc.nextInt();
        Queue<Integer> queue = new PriorityQueue<>();
        getZS(in, queue);
        while (queue.peek() != null) {
            System.out.print(queue.poll() + " ");
        }
    }

    //使用迭代的方法来优化
    public static void getZS(int n, Queue<Integer> queue) {
        double sqrt = Math.sqrt(n);
        while (n != 1) {
            int flag = 0;
            for (int i = 2; i <= sqrt; i++) {
                if (n % i == 0) {
                    flag = 1;
                    queue.offer(i);
                    n = n / i;
                    break;
                }
            }
            //如果 2 ~ sqrt 都无法除尽，那么直接取最大
            if (flag == 0) {
                queue.offer(n);
                break;
            }
        }
    }

}
